package com.catering.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.catering.entity.CateringSpacesChild;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CateringSpacesChildDao extends BaseMapper<CateringSpacesChild> {

    @Select("select t1.*,t2.spaces_name as parent_name from catering_spaces_child t1 left join catering_spaces t2 on t1.parent_id = t2.sys_id ${ew.customSqlSegment}")
    public IPage<CateringSpacesChild> selectPageList(IPage<CateringSpacesChild> page, @Param(Constants.WRAPPER) QueryWrapper<CateringSpacesChild> queryWrapper);

    @Select("select count(1) from catering_spaces_child t1 left join catering_spaces t2 on t1.parent_id = t2.sys_id ${ew.customSqlSegment}")
    public int selectPageCount(@Param(Constants.WRAPPER) QueryWrapper<CateringSpacesChild> queryWrapper);

    @Select("select t1.*,t2.spaces_name as parent_name from catering_spaces_child t1 left join catering_spaces t2 on t1.parent_id = t2.sys_id ${ew.customSqlSegment}")
    public List<CateringSpacesChild> selectNoPageList(@Param(Constants.WRAPPER) QueryWrapper<CateringSpacesChild> queryWrapper);

    public List<CateringSpacesChild> selectNameList(@Param(value = "qw") CateringSpacesChild child);
}
